﻿using AppDataStruct;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EECMISWS
{
    /// <summary>
    /// 核查结果（控制对象，国家工作人员）
    /// </summary>
    public enum CheckResult : int
    {
        Failed = -99,               // 核查失败
        Unknow = -1,            // 结果未知
        No = 0,                     // 核查结果不是
        Yes = 1,                    // 核查结果是
    }

    /// <summary>
    /// 核查信息查询结果
    /// </summary>
    public class PeopleCheckResult
    {
        /// <summary>
        /// 国家工作人员信息
        /// </summary>
        public OfficialInfo Offical { get; set; }

        /// <summary>
        /// 核查是否成功
        /// </summary>
        public bool Success
        {
            get
            {
                return (CheckOfficalResult == CheckResult.Yes || CheckOfficalResult == CheckResult.No);
                    //&& (CheckSpecialListResult == CheckResult.Yes || CheckSpecialListResult == CheckResult.No);
            }
        }

        /// <summary>
        /// 国家工作人员核查结果
        /// </summary>
        public CheckResult CheckOfficalResult { get; set; }

        /// <summary>
        /// 控制对象核查结果
        /// </summary>
        public CheckResult CheckSpecialListResult { get; set; }
       
        /// <summary>
        /// 如果查询包含多个来源，每个接口返回的错误消息以$分隔
        /// </summary>
        public string ErrorMessage { get; set; }
    
        /// <summary>
        /// 错误代码
        /// </summary>
        public string ErrorCode { get; set; }

        public PeopleCheckResult()
        {
            Reset();
        }

        public void Reset()
        {
            ErrorCode = "";
            CheckOfficalResult = CheckResult.Unknow;
            CheckSpecialListResult = CheckResult.Unknow;
            ErrorMessage = "";
        }

        public void SetErrorCode(object code)
        {
            ErrorCode = code.ToString();
        }

        public void SetError(string error)
        {
            if(string.IsNullOrEmpty(ErrorMessage))
            {
                ErrorMessage = error;
            }
            else
            {
                ErrorMessage += "$";
                ErrorMessage += error;
            }
        }
    }
}
